# datetime  时间日期相关
import datetime

# 当前日期时间
# nowtime = datetime.datetime.now()
# print(nowtime)
# print(nowtime.day)
# print(nowtime.month)
# print(nowtime.year)
# 转成时间戳
# print(nowtime.timestamp())
# 获取指定日期
# print(datetime.datetime(2021, 10, 10))

# 字符串与时间互相转换
# s = "2021-09-27 06:47:06"
# print(type(s))
# # 将字符串 转换为datetime 实例
# s1 = datetime.datetime.strptime(s, '%Y-%m-%d %H:%M:%S')
# print(s1)
# print(type(s1))
# # 时间转换成字符串
# result = s1.strftime('%a, %b %d %H:%M')
# print(result)

mtimestamp = 1657697747.702134

# 将时间戳转成时间
s = datetime.datetime.fromtimestamp(mtimestamp)
print(s)
# 将时间转成时间戳
print(s.timestamp())